-- SPDX-License-Identifier: GPL-3.0-or-later

local v_longxi = fk.CreateSkill {
  name = "v_longxi",
  tags = { Skill.Compulsory, },
}

v_longxi:addEffect(fk.TargetSpecified, {
  --赋予输出型技能定义,
  anim_type = "offensive",
  --触发条件：触发时机的角色为遍历到的角色，触发者拥有此技能，
  --触发者本回合只使用了第一张牌，触发者处于出牌阶段，
  --本次流程中第一次触发这个时机
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(v_longxi.name) 
    and player.phase == Player.Play then
      local use_events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
        local use = e.data
        return use.from == player
      end, Player.HistoryTurn)
      return #use_events == 1
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if not data.to:isNude() then
      local cid = room:askToChooseCard(
        player, {
          target = data.to,
          flag = "he",
          skill_name = v_longxi.name,
        }
      )
      room:throwCard(cid, v_longxi.name, data.to, player)
    end
  end,
})

return v_longxi